<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <!-- 最接近的因数 -->
    <script>
      var closestDivisors = function (num) {
        for (let i = parseInt(Math.sqrt(num + 2)); i >= 1; i--) {
          //开根号一定要num+2,是否可缩小有点像数学性质
          if ((num + 1) % i == 0) {
            var k = (num + 1) / i
            return [i, k]
          }
          if ((num + 2) % i == 0) {
            var k = (num + 2) / i
            return [i, k]
          }
        }
      }
      console.log(closestDivisors(8))
    </script>
  </body>
</html>
